#!/bin/bash

# 停止并移除现有容器
echo "Stopping and removing existing containers..."
docker-compose down

# 重新构建所有服务镜像
echo "Rebuilding services..."
docker-compose build

# 启动服务并自动重建
echo "Starting Docker Compose with rebuild..."
docker-compose up --build -d

# 收集静态文件
echo "Collecting static files..."
docker-compose exec django-app python manage.py collectstatic --noinput

# 提示操作完成
echo "Docker Compose project has been restarted and configured."
echo "Static files collected."

# 按任意键继续（在终端中按回车即可退出脚本）
read -p "Press Enter to continue..."